﻿using Microsoft.Extensions.Primitives;
using Yarp.ReverseProxy.Configuration;

namespace EMall.AdminGateway
{

    public class YarpProxyConfig : IProxyConfig
    {
        private readonly List<RouteConfig> _routes;
        public IReadOnlyList<RouteConfig> Routes => _routes.AsReadOnly();
        private readonly List<ClusterConfig> _clusters;
        public IReadOnlyList<ClusterConfig> Clusters => _clusters.AsReadOnly();
        public IChangeToken ChangeToken { get; internal set; }
        public YarpProxyConfig()
        {
            _routes = new List<RouteConfig>();
            _clusters = new List<ClusterConfig>();
        }
        public YarpProxyConfig(List<RouteConfig> routes, List<ClusterConfig> clusters) : this()
        {
            _routes = routes;
            _clusters = clusters;
        }
        public void AddRoutes(params RouteConfig[] routeConfigs)
        {
            _routes.AddRange(routeConfigs);
        }
        public void AddClusters(params ClusterConfig[] clusterConfigs)
        {
            _clusters.AddRange(clusterConfigs);
        }

    }
}
